<template>
 <div class="d-flex jc-between px-2">
   <div class="d-flex" style="width: 40%">
     <div
       class="react-right ml-4"
       style="width: 6.25rem; text-align: left;background-color: #0f1325;"
     >
       <span class="react-before"></span>
       <span class="text" style="font-size: 0.3rem;" @click="goIndex">
         <i class="el-icon-arrow-left"></i>
        {{roleName}}
       </span>
     </div>
     <div class="react-right ml-3" style="background-color: #0f1325;">
     </div>
   </div>
   <div class="d-flex" style="width: 40%;justify-content: end" >
     <div class="react-left mr-3"  style="background-color: #0f1325;">
     </div>
     <div
       class="react-left mr-4"
       style="width: 6.25rem; background-color: #0f1325; text-align: right;"
     >
       <span class="react-after"></span>
       <span class="text">{{time}}</span>
     </div>
   </div>
 </div>

</template>

<script>
  export default {
    name: "Screen",
    components: {},
    data() {
      return {
        roleId: sessionStorage.getItem("roleId"),
        roleName:'全平台',
        time:'',
        weeks:['日','一','二','三','四','五','六'],
      };
    },
    created() {
      this.setName()
      this.setTime()
      setInterval(()=>{
          this.setTime()
      },2000)
    },
    methods: {
      setName(){
        if(sessionStorage.getItem("user")){
          let data=JSON.parse(sessionStorage.getItem("user"))
          if(this.roleId!=2){
            this.roleName=data.dept.deptName
          }
        }
      },
      setTime(){
         let now=new Date(),
         month=now.getMonth()+1,
         date=now.getDate(),
         hours=now.getHours(),
         minutes=now.getMinutes();
         this.time=now.getFullYear()+'年'+(month<10?('0'+month):month)
         +'月'+(date<9?('0'+date):date)+'日 周'+this.weeks[now.getDay()]+' '+(hours<9?('0'+hours):hours)+':'+(minutes<9?('0'+minutes):minutes)
      },
      goIndex(){
        this.$router.push({path:'/index'})
      },
    },
  };
</script>
